package com.example.service.imgImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.example.domain.childer_articles;
import com.example.domain.lease_review;
import com.example.mapper.img.imgQuery;
import com.example.service.img.imgService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class imgServiceImpl extends ServiceImpl<imgQuery,lease_review> implements imgService{
    @Resource
    private imgQuery imgQuery;

    @Override
    public boolean shangchuan(lease_review lease_review) {
        return imgQuery.insert(lease_review)>0;
    }

    @Override
    public List<lease_review> findall(int a, int b) {
        return imgQuery.selectall(a,b);
    }

    @Override
    public IPage<lease_review> getPage(int currentPage, int pageSize, lease_review review) {
        System.out.println("aaa");
        System.out.println(currentPage);
        System.out.println(pageSize);
        LambdaQueryWrapper<lease_review> lqw = new LambdaQueryWrapper<lease_review>();
        lqw.like(Strings.isNotEmpty(review.getTitle()),lease_review::getTitle,review.getTitle());
        lqw.eq(lease_review::getFit,review.getFit());
        IPage page = new Page(currentPage,pageSize);
        imgQuery.selectPage(page,lqw);
        return page;
    }

    @Override
    public IPage<lease_review> getPagebyname(int currentPage, int pageSize, lease_review review) {
        System.out.println("aaa");
        System.out.println(currentPage);
        System.out.println(pageSize);
        LambdaQueryWrapper<lease_review> lqw = new LambdaQueryWrapper<lease_review>();
        lqw.like(Strings.isNotEmpty(review.getTitle()),lease_review::getTitle,review.getTitle());
//        lqw.eq(childer_articles::getFit,articles.getFit());
        IPage page = new Page(currentPage,pageSize);
        imgQuery.selectPage(page,lqw);
        return page;
    }


    @Override
    public lease_review selectBYid(int id) {
        return imgQuery.selectById(id);
    }

    @Override
    public boolean deletelease_review(int id) {
        return imgQuery.deleteById(id)>0;
    }

}
